﻿using System;
using CollegeSim.Domain.Entities;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace CollegeSim.Domain.Test.Entities
{
    // Author: Ryan Redburn
    // Project: CollegeSim
    // Date: 5/13/2014

    [TestClass]
    public class SemesterTest
    {
        #region [ SemesterID ]

        [TestMethod]
        public void SemesterID_DefaultValue_EqualsExpected()
        {
            // Arrange
            var semester = new Semester();

            // Assert
            Assert.AreEqual(0, semester.SemesterID);
        }

        #endregion

        #region [ Name ]

        [TestMethod]
        public void SemesterName_Empty_ArgumentNullException()
        {
            // Arrange
            var assert = false;
            var semester = new Semester
            {
                Name = "Spring"
            };

            try
            {
                // Act
                semester.Name = "";
            }
            catch (ArgumentNullException)
            {
                assert = true;
            }
            finally
            {
                // Assert
                Assert.IsTrue(assert);
            }
        }

        [TestMethod]
        public void SemesterName_Null_ArgumentNullException()
        {
            // Arrange
            var assert = false;
            var semester = new Semester
            {
                Name = "Spring"
            };

            try
            {
                // Act
                semester.Name = null;
            }
            catch (ArgumentNullException)
            {
                assert = true;
            }
            finally
            {
                // Assert
                Assert.IsTrue(assert);
            }
        }

        [TestMethod]
        public void SemesterName_AboveLength_ArgumentOutOfRangeException()
        {
            // Arrange
            var assert = false;
            var semester = new Semester
            {
                Name = "Spring"
            };

            try
            {
                // Act
                semester.Name = "Spring Spring Spring";
            }
            catch (ArgumentOutOfRangeException)
            {
                assert = true;
            }
            finally
            {
                // Assert
                Assert.IsTrue(assert);
            }
        }

        #endregion
    }
}
